$(function() {
    var $dialog = $('<div/>');
    var $formBody = $('#form-body');
    $dialog.dialog({
        height: 300,
        width: 500,
        content: $formBody.show(),
        noheader: true,
        buttons: [{
            id: 'loginBtn',
            disabled: false,
            text: '登&nbsp;&nbsp;录',
            iconCls:"icon-ok",
            handler:function(){
            	var linkbutton = $(this);
            	linkbutton.linkbutton("disable");
            	formSubmit(linkbutton);
            	linkbutton.linkbutton("enable");
            }
        }]
    });
    $formBody.after($('#logo').show());
    $(window).resize(function() {
        $dialog.dialog('center');
    });
    $('#form-body input').keyup(function(event){
		if(event.which==13){
			formSubmit();
			$('#form2 input').blur();
		} 
		return false;
	}); 

	var formSubmit = function() {
		$.post('auth/MngUserController/doNotNeedSecurityLogin.do',
				$formBody.serialize(), function(rsp) {
					if (rsp.success) {
						window.location = rsp.obj;
					} else {
						$.messager.alert('警告', rsp.msg);
					}
				}, 'json').error(function() {
			$.messager.alert('警告', '系统发生错误');
		});
	}
});